package com.hqu.ms.map;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import com.baidu.mapapi.map.ItemizedOverlay;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayItem;
import com.baidu.mapapi.map.PopupClickListener;
import com.baidu.mapapi.map.PopupOverlay;
import com.baidu.platform.comapi.basestruct.GeoPoint;
import com.hqu.ms.R;
import com.hqu.ms.entities.StoreEntivity;

public class MSOverlay extends ItemizedOverlay<OverlayItem> {

	  public List<OverlayItem> mGeoList = new ArrayList<OverlayItem>();
		private Context mContext = null;
	    static PopupOverlay pop = null;
	    private Drawable marker;
	    private Bitmap popBitmap;
		public MSOverlay(Drawable marker,Context context,Bitmap popBmp, MapView mapView){
			super(marker);
			this.mContext = context;
			this.marker = marker;
			popBitmap = popBmp;
	        pop = new PopupOverlay(mapView ,new PopupClickListener() {
				
				@Override
				public void onClickedPopup() {
					
					 pop.hidePop();
				}
			});
		    populate();
		}
		
		
		protected boolean onTap(int index){
		    pop.showPopup(popBitmap, mGeoList.get(index).getPoint(), 55);
			super.onTap(index);
			return false;
//			// int latspan = this.getLatSpanE6();
//			// int lonspan = this.getLonSpanE6();
		}

		
		public boolean onTap(GeoPoint pt, MapView mapView){
			if (pop != null){
				pop.hidePop();
			}
			super.onTap(pt,mapView);
			return false;
			
		}
		
		@Override
		protected OverlayItem createItem(int i) {
			return mGeoList.get(i);
		}
		
		@Override
		public int size() {
			return mGeoList.size();
		}
		public void addItem(OverlayItem item){
			mGeoList.add(item);
			populate();
		}
		public void removeItem(int index){
			mGeoList.remove(index);
			populate();
		}

}
